﻿using ShineTech.Domain.Models.Missons;
using ShineTech.Domain.SeedWork;
using System;
using System.Collections.Generic;
using System.Text;

namespace ShineTech.Domain.Models.Kanbans
{
    public class Kanban : Entity, IAggregateRoot
    {
        public string Name { get; private set; }

        public Guid CreatedUserId { get; private set; }

        public string CreatedUserName { get; private set; }

        public DateTime CreatedTime { get; private set; }
        /// <summary>
        /// 任务
        /// </summary>
        public virtual ICollection<Misson> Missons { get; set; }


        public Kanban(string name, Guid createdUserId, string createdUserName, DateTime createdTime)
        {

            if (string.IsNullOrEmpty(name))
                throw CustomException.NullArgument(nameof(name));
            if (string.IsNullOrEmpty(createdUserName))
                throw CustomException.NullArgument(nameof(createdUserName));

            Name = name;
            CreatedTime = createdTime;
            CreatedUserId = createdUserId;
            CreatedUserName = createdUserName;


        }
        public Kanban() { }
        /// <summary>
        /// 列表中增加任务
        /// </summary>
        /// <param name="misson"></param>
        public void AddMisson(Misson misson)
        {
            this.Missons.Add(misson ?? throw CustomException.NullArgument(nameof(misson)));
        }
        public void Update(string name) {
            this.Name = name;
        }

    }
}
